<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <link rel="stylesheet" href="/css/elementUI.css">
    <script src="/js/vue.js"></script>
    <script src="/js/elementUI.js"></script>
    <script src="/js/axios.js"></script>
</head>
<body>


<div id="app">
    账号：<el-input v-model="emp.worknum" placeholder="请输入工号" style="width: 200px;" ></el-input>
    <br>
    密码：<el-input v-model="emp.idcard" placeholder="请输入身份证后六位" style="width: 200px;" ></el-input>
    <br>
    <el-checkbox v-model="isHr">我是HR</el-checkbox>
    <br>
    <el-button @click="login" type="primary">登录</el-button>
</div>
<script>
    new Vue({
        el:"#app",
        data:{
            emp:{
                worknum:"",
                idcard:""
            },
            isHr:false,
        },
        watch:{
        },
        methods:{
            login(){

                axios.post("/emp/login?isHr="+this.isHr,this.emp).then(res=>{
                    //返回的时时候，如果返回当前登录人对象，登录成功；如果返回普通字符串，就是错误信息
                    if(res.data.id){
                        this.$message.success("登录成功")
                        if(this.isHr){
                            location.href = "salary_construct.html";
                        }else{
                            location.href = "emp.html";
                        }
                    }else{
                        this.$message.error(res.data)
                    }

                })

            },
            initData(){

            }

        },
        created(){
            this.initData()
        }
    })
</script>


</body>
</html>